#ifndef SNCPACKET_HH
#define SNCPACKET_HH 1
#include <click/config.h>
#include "list.hh"
#include <click/packet.hh>
#include <click/vector.hh>
//using namespace SNCoding;

CLICK_DECLS

#define DBUG

#ifndef DBUG
#define DPrintf
#else
#define DPrintf(arg...) printf(arg)
#endif


//#define SNC_ACK		0x01
//#define SNC_REPORT	0x02
#define SNC_NO_DATA			0x01
#define SNC_DATA_NORMAL		0x02
#define SNC_DATA_ENCODED	0x04
#define SNC_LINK_CREDITS    0x08

//**********************************************************
// |        TYPE   8bits       						   |
// |        ENCODED_NUM   8bits     				   |
// |              ...               				   |
// | PKT_ID 32bits | NEXTHOP 48bits 				   |   //not include the packet to this host
//!!!!!!!!discard // | CODE_VECTOR (8*ENCODED_NUM)bits |
// |        REPORT_NUM    8bits     				   |
// | SRC_IP 16bits | LAST_PKT 16bits | BIT_MAP 8bits   |
// |              ...                                  |
// |        ACK_NUM       8bits                        |
//????????discard |     LOCAL_PKT_SEQ_NUM 16bits       |
// | NEIGHBOR 48bits | LAST_ACK 16bits | ACK_MAP 8bits |
// |              ...                                  |
//**********************************************************
typedef uint8_t bitmap_sizetype;

#define byte_size 8

CLICK_SIZE_PACKED_STRUCTURE(struct encoded_header {,
	uint32_t	_pkt_id;
	uint8_t		_next_hop[6];
});

CLICK_SIZE_PACKED_STRUCTURE(struct report_header {,
	uint32_t	_src_ip;
	uint16_t	_last_pkt;
	bitmap_sizetype		_bit_map;
});

CLICK_SIZE_PACKED_STRUCTURE(struct ack_header {,
	uint8_t		_neighbor[6];
	uint16_t	_last_ack;
	bitmap_sizetype		_bit_map;
});

#define MAKE_PKT_ID(ip,seqno) ((ip)<<16 | (uint32_t)(seqno))


struct sendp{
	Packet*		_p;
	uint8_t		_retry;
	uint16_t 	_local_seqno;
};

//typedef List

struct ack{
	uint8_t			_dst[6];
	SNCoding::List<uint16_t > _seqno;
};

struct report{
	uint32_t _src_ip;
	SNCoding::List<uint16_t > _seqno;
};

struct NativePkt{
	uint32_t _src_ip;
	uint16_t _seqno;
	uint8_t* _data;
	uint16_t _size;
};

typedef SNCoding::List<Packet* > Packet_list;

//typedef Packet_list::iterator Packet_v;

typedef SNCoding::List<Packet* >::iterator Packet_v;

typedef Vector<Packet* > Natives;

typedef Vector<Packet* > Encodeds;



CLICK_ENDDECLS


#endif
